<script>
	import store from './store'
	import { userApi } from '@/http/userApi.js'
	import { USER_TOKEN } from '@/constants/local-storage-key-const';
	export default {
		onLaunch: function() {
			let that = this;
			const token = uni.getStorageSync(USER_TOKEN)
			that.setWxHeader()
			if(token){
				that.setUserInfo()
			}
		},
		onShow: function() {
			console.log('App Show')
			
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
			setWxHeader(){
				let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
				// #ifdef MP 
				let menuButtonHeight = uni.getMenuButtonBoundingClientRect().height;
				let titleBarWidth = uni.getSystemInfoSync().windowWidth - uni.getMenuButtonBoundingClientRect().width - (uni.getSystemInfoSync().windowWidth - uni.getMenuButtonBoundingClientRect().right) * 2;
				let titleBarHeight = (uni.getMenuButtonBoundingClientRect().top - statusBarHeight) * 2 + menuButtonHeight;
				store.commit('setWxHeader',{
					'statusBarHeight':statusBarHeight,
					'menuButtonHeight':menuButtonHeight,
					'titleBarWidth':titleBarWidth,
					'titleBarHeight':titleBarHeight
				})
				// #endif
				// #ifdef APP
				store.commit('setStatusBarHeight',statusBarHeight)
				// #endif
			},
			async setUserInfo(){
				try{
					const usr = await userApi.getUserInfo()
					store.commit('setLogin',usr)
				}catch(e){
					
				}
			},
		}
	}
</script>

<style>
	/* #ifndef APP-PLUS-NVUE */
	@import './theme/iconfont.css';
	@import './theme/index.css';
	.main{
		background-image: url('https://168809.oss-cn-hangzhou.aliyuncs.com/community/temp/yuebg.png');
		background-repeat: no-repeat;
		background-size: cover;
		background-position: 0 100%;
		min-height: 100vh;
	}
	.wxbutton{background-color: #70dec1;color: #FFFFFF;font-size: 28rpx;height:90rpx;border-radius: 60rpx;width: 100%;}
	.wxbutton::after{border-width: 0;}
	button[disabled]:not([type]){color: rgba(0,0,0,.3);background-color:#dedede}
	button[disabled]:not([type]){color:#bfbfbf;background-color:#F2F2F2}
	/* #endif*/
</style>
